\subsection{The Formal  Model}\label{sec:formal}


Let  \(D\) be a set of documents  and let \(A\) be a set of user agendas as we define shortly. Let \(S\) be a set of English sentences  over a finite vocabulary \(S=\Sigma^*\). Our system implements a function that maps each \(\langle document,agenda\rangle\) pair to  a natural language response sentence \(s\in S\).
\[f_{\rm response}:  {D}\times  {A}\rightarrow  {S}\]


Response generation takes place in two phases, roughly corresponding to   macro and micro planning in \newcite{Reiter:1997:BAN:974487.974490}:
\begin{itemize}
\item Macro Planning (below, the {\em analysis} phase): What are we going to talk about?
\item  Micro Planning (below, the {\em generation} phase): How are we going to say it?
\end{itemize}
%
%The  analysis function $p(\cdot)$ maps a document to a subjective representation of its content.\footnote{A content element may conceivably encompass a topic, its sentiment, its objectivity, its evidentiality, its perceived truthfulness, and so on. In this paper we focus on topic and sentiment,   and leave the rest for future research.}
%\[p: {D}\rightarrow {C}\]
The  analysis function $p: {D}\rightarrow {C}$ maps a document to a subjective representation of its content.\footnote{A content element may conceivably encompass a topic, its sentiment, its objectivity, its evidentiality, its perceived truthfulness, and so on. In this paper we focus on topic and sentiment,   and leave the rest for future research.}
%The generation function $g(\cdot)$ intersects the subjective content  elements and the subjective user agenda, and generates a response based on the content of the intersection:
%\[g: {C}\times {A}\rightarrow  {S}\]
The generation function $g: {C}\times {A}\rightarrow  {S}$ intersects the   content  elements in the document and in the user agenda, and generates a response based on the content of the intersection:
All in all, our system implements a composition of the analysis and  the generation  functions:
\[f_{\rm response}(d,a)=g(p(d),a)=s \]


%Both the subjective content   \(c\in C\) and the subjective agenda  \(a\in A\) are objects of type set containing  topics associated with a subjective component.  The subjective component is a sentiment measure, which assigns each topic a scalar value that reflects how positive / negative is the  content element.

Both a content element \(c\in C\) and an agenda item \(a\in A\) is a topic $t$  associated with a sentiment value    \(sentiment_t \in [-n..n] \) that signifies the (negative or positive) disposition of the document's author (if \(c\in C\)) or the user's agenda (if \(a\in A\))  towards the topic.
% \[ \langle topic, sentiment_t \rangle \]
We assume here that a topic is simply a bag of words from our vocabulary \(\Sigma\). Thus, we   have the following:
% (where elements  \(a\in A\) or \(c\in C\) may be weighted with respect to significance).
\[A,C\subseteq \mathcal{P}(\Sigma)\times [-n..n]\]



Our generation component accepts the result of the intersection as input and relies on  a template-based  grammar and a set of functions of generating referring expressions in order to construct the output.   To make the responses {\em economic}, we limit the content of a response to one statement about the document or its author, followed by a statement on the relevant topic. To  make the response {\em relevant}, the templates that generate the response make use of topics in the intersection of  the document and the agenda.
To make the response {\em opinionated}, the sentiment of the response depends on the (mis)match between the sentiment values for the topic in the document and in the agenda.
%The generated responses are natural language sentences which reflect the topic(s) in the intersection of the article contents and the user agenda.  The   sentiment of the response is based on the sentiments of both document and agenda.
Concretely, the response is positive if the sentiments for the topic in the document and agenda are the same (both positive or both negative) and it is negative otherwise. %This is effectively captured  in Table~\ref{truth}.
%\begin{table}
%\center
%\scalebox{0.9}{\begin{tabular}{|cc|c|}\hline
%Document & Agenda& Response  \\
%sentiment & sentiment & sentiment \\
%\hline
%positive & positive & positive  \\
%positive & negative & negative  \\
%negative & negative & positive  \\
%negative &  positive & negative  \\\hline
%\end{tabular}}
%\caption{The Truth Table of  Subjective Responses.}\label{truth}
% \end{table}


%\paragraph{System Variants}
We suggest two variants of the generation function \(g\). The basic variant implements the baseline function defined above: \[g_{\rm base}(c,a)=s\]
\[c\in C, a\in A, s\in\Sigma^*\]
%\[g_{\rm base}(c,a)=s\]
%\[c\in C, a\in A, s\in\Sigma^*\]

For the other variant we define a knowledge base ($KB$) as a directed graph in which words  \(w\in\Sigma\) from the topic models correspond to nodes in the graph, and  relations  \(r\in R\)  between the words are predicates that hold  in the real world.
Our second generation function now becomes: \[g_{\rm kb}(c,a, KB)=s\] \[KB\subseteq\{(w_i,r,w_j)| w_i,w_j\in \Sigma, r\in R\}\]
with \( c\in C, a\in A, s\in\Sigma^*\)  as defined in \(g_{\rm base}\) above.
